package com.llh.demo4shiro.controller;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * <p>CreatedAt: 2020/9/16 15:57</p>
 *
 * @author llh
 */
@Controller
public class RouterController {

    @GetMapping(value = {"", "welcome"})
    public String welcome() {
        return "welcome";
    }

    @GetMapping(value = {"user"})
    public String userRegister() {
        return "user";
    }

    @GetMapping(value = {"role/add"})
    public String roleAdd() {
        return "role/add";
    }

    @GetMapping(value = {"role"})
    @RequiresRoles("admin")
    public String roleIndex() {
        return "role/index";
    }
    @GetMapping(value = {"authority"})
    public String authorityIndex() {
        return "authority";
    }
    @GetMapping(value = {"login"})
    public String login() {
        return "login";
    }

    @GetMapping(value = {"error"})
    @RequiresAuthentication // 表示当前Subject已经通过login 进行了身份验证
    public String error() {
        return "error";
    }
}
